import {currentDates,secondss} from '../../utils/util'
Page({
  data: {
    // 评分
    rate: [],
    num:9
  },
  onLoad({ params }) {
    let { type, s_id, gs_id } = JSON.parse(params)
    if (type == 2) {
      this._getEvaluate({ type, s_id })
    } else if (type == 1) {
      this._getEvaluate({ type, gs_id })
    }
  },
  // 获取当前亲子游戏价格
  async _getEvaluate({ type, s_id, gs_id }) {
    let { code, data } = await wx.requestAsync({
      url: '/evaluate',
      data: {
        page: 1,
        type,
        s_id,
        gs_id,
      },
    })
    if (code == 0) {
      let rate = data.map((item) => {
        item.pics = item.pics.split(',')
        item.create_at = currentDates(item.create_at*1000) + ' ' +  secondss(item.create_at) 
        return item
      })
      this.setData({ rate })
    }
  },
})
